package com.example.mapper;

import com.example.entity.Address;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface AddressMapper {
    void addaddress(Address address);


    @Update("update address set is_default = #{isDefault} where user_id=#{userId};")
    void updateIsDefaultByUserId(Address address);

    void update(Address address);

    List<Address> getAll(Integer userId);

    @Delete("delete from address where id=#{id}")
    void deleteById(Integer id);

    @Select("select * from address where id=#{id}")
    Address getById(Integer id);

    @Select("select * from address where is_default=1 and user_id=#{id}")
    Address getDefault(Integer userId);
}
